<?php
require_once 'cloudfiles/cloudfiles.php';

class Custom_Api_Rackspace_Cloud
{
	private $Container = '';

	public function  __construct($container = 'grepsr-avatars') {

		$config = Zend_Registry::get('config');
		$rackAuth = new CF_Authentication($config->params->rackspace->user, $config->params->rackspace->api);
		$rackAuth->authenticate();
		$rackConn = new CF_Connection($rackAuth, $config->params->rackspace->serviceNet);

		$objContainer = $rackConn->get_container($container);
		$this->Container = $objContainer;
	}

	public function uploadFile($path, $fileName)
	{
		$object = $this->Container->create_object($fileName);
		$res = $object->load_from_filename($path);

		return $res;
	}

}

